package com.example.study.controller;


import com.example.study.pojo.Logs;
import com.example.study.service.LogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 喜欢多云的季节
 * @since 2022-04-20
 */
@RestController

@RequestMapping("/study/logs")

public class LogsController {
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private LogsService logsService;
   /**
    * @title getAllLogs
    * @author 田起立 
    * @description
    * @updateTime 2022/8/18 15:22 null
    * @return null
    */
    @PreAuthorize("hasAuthority('system:read')")
    @GetMapping("/select")
    public  List<Logs> getAllLogs(){
        List<Logs> list = logsService.list(null);
        return list;

    }
    /**
     * @title selectByAccount
     * @author 田起立 
     * @description 
     * @updateTime 2022/8/18 14:54 null
     * @throws 
     * @return null
     */
    @PreAuthorize("hasAuthority('system:admin')")
    @GetMapping("/selectByAccount")
    public  List<Map<String,Object>> selectByAccount(@RequestParam("account")String account){
        Map<String, Object> params = new HashMap<>();
        params.put("account",account);
        List<Map<String,Object>> list = logsService.selectByAccount(params);
        return list;
    }
}

